import Vue from 'vue'
import Vuex from 'vuex'
import app from './modules/app'
import user from './modules/user'
import tagsView from './modules/tagsView'
import permission from './modules/permission'
import settings from './modules/settings'
import getters from './getters'

// 子版块vuex
const moduleFiles =require.context('@/plugs', true, /index.js$/)
const getMoudle = {};
moduleFiles.keys().forEach(value => {
  const moduleName = value.replace(/^\.\/(.*)\.\w+$/, '$1')
  const Name = moduleName.split("/")[0];
  getMoudle[Name] = Object.assign({}, moduleFiles(value).default)
})
Vue.use(Vuex)

const modules = {
  app,
  user,
  tagsView,
  permission,
  settings,
  ...getMoudle

};
const store = new Vuex.Store({
  modules,
  getters
})

export default store
